package com.elmcode.server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.elmcode.common.utils.PageUtils;
import com.elmcode.server.entity.CategoryEntity;
import com.elmcode.server.entity.FoodEntity;
import com.elmcode.server.service.CategoryService;
import com.elmcode.server.service.FoodService;
import com.elmcode.server.service.MenuService;
import com.elmcode.server.vo.MenuVo;
import com.elmcode.server.vo.ShopInfoVo;
import com.elmcode.server.vo.shopDetailVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.awt.geom.QuadCurve2D;
import java.util.List;
import java.util.stream.Collectors;

@Slf4j
@Service
public class MenuServiceImpl implements MenuService {

    @Autowired
    private CategoryService categoryService;

    @Autowired
    private FoodService foodService;

    @Override
    public MenuVo selectMenuInfo() {

        MenuVo menuVo = new MenuVo();

        List<CategoryEntity> entityList =  categoryService.selectAllCategory();
        List<ShopInfoVo> collect = entityList.stream().map(item -> {
            ShopInfoVo shopInfoVo = new ShopInfoVo();
            List<shopDetailVo> shopDetailVos = foodService.selectByCategoryId(item.getId());

            shopInfoVo.setId(item.getId());
            shopInfoVo.setName(item.getName());
            shopInfoVo.setFoodSimpleVOList(shopDetailVos);

            return shopInfoVo;
        }).collect(Collectors.toList());

        menuVo.setShopInfoVos(collect);
        return menuVo;
    }
}
